<#include "/common/defaultEngine.html"/>
<@pageTheme mark="${config.optimize()?string('true', 'false')}">
<@header title="设备管理" libs=["table"]/>
<div class="container-div" id="_app">
    <div class="row">
        <div class="col-sm-12 search-collapse">
            <@f.form id="module-form">

            <!--我们在body中加入一个div，里面放入一个table-->
            <div style="display:none" id="test">
                <h4>高级查询</h4>
                <hr>
                <table class="table table-striped">
                    <tbody>
                    <tr>
                        <td><@ctx.i18n text = "部门名称"/>：</td>
                        <td><input type="text" class="form-control" name="department2"  placeholder="请输入部门名称"></td>
                        <td><@ctx.i18n text = "设备编码"/>：</td>
                        <td><input type="text" class="form-control" name="equipmentCode2"  placeholder="请输入设备编码"></td>
                    </tr>
                    <tr>
                        <td><@ctx.i18n text = "设备名称"/>：</td>
                        <td><input type="text" class="form-control" name="equipmentName"  placeholder="请输入设备名称"></td>
                        <td><@ctx.i18n text = "型号"/>：</td>
                        <td><input type="text" class="form-control" name="equipmentModel"  placeholder="请输入型号"></td>
                    </tr>
                    <tr>
                        <td><@ctx.i18n text = "净残值率"/>：</td>
                        <td><input type="text" class="form-control" name="jingcanValue"  placeholder="请输入净残值率"></td>
                        <td><@ctx.i18n text = "使用年限"/>：</td>
                        <td><input type="text" class="form-control" name="age"  placeholder="请输入使用年限"></td>
                    </tr>
                    <tr>
                        <td><@ctx.i18n text = "设备原值"/>：</td>
                        <td><input type="text" class="form-control" name="equipmentValue"  placeholder="请输入设备原值"></td>
                        <td><@ctx.i18n text = "净残值"/>：</td>
                        <td><input type="text" class="form-control" name="worthValue"  placeholder="请输入净残值"></td>
                    </tr>
                    <tr>
                        <td><@ctx.i18n text = "净值"/>：</td>
                        <td><input type="text" class="form-control" name="worth"  placeholder="请输入净值"></td>
                        <td><@ctx.i18n text = "本月折旧"/>：</td>
                        <td><input type="text" class="form-control" name="monthDepreciation"  placeholder="请输入本月折旧"></td>
                    </tr>
                    <tr>
                        <td><@ctx.i18n text = "累计折旧"/>：</td>
                        <td><input type="text" class="form-control" name="totalDepreciation"  placeholder="请输入累计折旧"></td>
                        <td></td>
                        <td></td>
                    </tr>
                    <tr>
                        <td class="select-time" colspan="4"><label>入账日期：&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</label><input type="text" name="beginTime" class="layui-input" placeholder="请输入选择时间" id="timeSelect" style="width: 150px" ><label>--</label><input type="text" name="endTime" class="layui-input" placeholder="请输入选择时间" id="timeSelect2" style="width: 150px"></td>
                    </tr>
                    </tbody>
                    <tfoot>
                    <tr>
                        <td colspan="2" align="center"><a class="btn btn-primary btn-rounded btn-sm" id="search" onclick="$.table.search()"><i class="fa fa-search"></i>  <@ctx.i18n text = "查询"/></a></td>
                        <td colspan="2" align="center"><a class="btn btn-warning btn-rounded btn-sm" onclick="opt.form.reset()"><i class="fa fa-refresh"></i> <@ctx.i18n text = "重置"/></a></td>
                    </tr>
                    </tfoot>
                </table>
            </div>
            <!--里面放入一个table-->

            <div class="select-list">
                <ul>
                    <li class="select-time">
                        <label>部门名称： </label>
                        <@f.input id="startTime" name="department" value=""/>
                    </li>
                    <li class="select-time">
                        <label>设备编码： </label>
                        <@f.input id="startTime" name="equipmentCode" value=""/>
                    </li>
                    <li>
                        <a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i class="fa fa-search"></i>  <@ctx.i18n text = "查询"/></a>
                        <a class="btn btn-warning btn-rounded btn-sm" onclick="opt.form.reset()"><i class="fa fa-refresh"></i> <@ctx.i18n text = "重置"/></a>
                        <a class="btn btn-primary btn-rounded btn-sm" id="searchall"><i class="fa fa-search"></i>  <@ctx.i18n text = "高级查询"/></a>
                    </li>
                    <li>
                        <@shiro.hasPermission name="bus:depreciation:export">
                        <a class="btn btn-warning  btn-rounded btn-sm" onclick="$.table.exportExcel()">
                            <i class="fa fa-download"></i> 导出
                        </a>
                        <a class="btn btn-info"  id="licSelect">
                            <i class="fa fa-upload"></i> 导入
                            <!--<input   id="files"  type="file" />-->
                            <!--<input type="file" id="files" value="" style="display:none">-->
                        </a>
                        </@shiro.hasPermission>
                    </li>
                </ul>

            </div>

        </@f.form>
    </div>
    <@table id="bootstrap-table">
    <!--<@shiro.hasPermission name="bus:equipment:add">-->
    <!--<a class="btn btn-success" onclick="opt.operate.add(0)">-->
        <!--<i class="fa fa-plus"></i> <@ctx.i18n text = "新增"/>-->
    <!--</a>-->
<!--</@shiro.hasPermission>-->
<!--<@shiro.hasPermission name="bus:equipment:edit">-->
<!--<a class="btn btn-primary" onclick="opt.operate.edit()">-->
    <!--<i class="fa fa-edit"></i> <@ctx.i18n text = "修改"/>-->
<!--</a>-->
<!--</@shiro.hasPermission>-->
<!--<@shiro.hasPermission name="bus:equipment:del">-->
<!--<a class="btn btn-danger multiple disabled" onclick="opt.operate.delAll()">-->
    <!--<i class="fa fa-remove"></i> <@ctx.i18n text = "删除"/>-->
<!--</a>-->
<!--</@shiro.hasPermission>-->

<!--onclick="upload()"-->
<!--<a class="btn btn-info"  id="licSelect">-->
    <!--<i class="fa fa-upload"></i> 导入-->
    <!--&lt;!&ndash;<input   id="files"  type="file" />&ndash;&gt;-->
    <!--&lt;!&ndash;<input type="file" id="files" value="" style="display:none">&ndash;&gt;-->
<!--</a>-->



</@table>
</div>
</div>
<@footer>
<script type="text/javascript">
    var statusDatas = ${dict.getDictListJson('project_status')};
    var statusDatas1 = ${dict.getDictListJson('project_type')};
    var editFlag = "${permission.hasPermi("bus:depreciation:edit")}";
    var listFlag = "${permission.hasPermi("bus:depreciation:add")}";
    // var categoryDatas = ${dict.getDictListJson('sys_bpm_category')};
    var prefix = baseURL + "bus/depreciation";

    $(function() {
        var options = {
            url: prefix + "/list",
            showSearch: false,
            showRefresh: false,
            showToggle: false,
            showColumns: false,
            clickToSelect: true,
            sortName: "id",
            delUrl: prefix + "/del",
            addUrl: prefix + "/add",
            editUrl: prefix + "/edit/{id}",//认领箱
            exportUrl: prefix + "/export",
            importUrl: prefix + "/import",
            uniqueId: 'id' , /* 唯一ID */
            modalName: "折旧报表",
            onDblClickRow: onDblClickRow,
            columns: [
                // {field: 'selectItem', radio: true},
                {title: $.i18n.prop("序号"), width: 5, align: "center", formatter: function (value, row, index) {
                        return $.table.serialNumber(index);}},
                {field:'department',   title: '<@ctx.i18n text = "部门名称"/>'},
                {field:'equipmentCode',    title: '<@ctx.i18n text = "设备编码"/>'},
                {field:'equipmentName',title: '<@ctx.i18n text = "设备名称"/>'},
                {field:'equipmentModel',title: '<@ctx.i18n text = "型号"/>'},
                {field:'createTime',title: '<@ctx.i18n text = "入账日期"/>'},
                {field:'jingcanValue',title: '<@ctx.i18n text = "净残值率"/>'},
                {field:'age',title: '<@ctx.i18n text = "使用年限"/>'},
                // {field: 'payType', title: "<@ctx.i18n text = '支付状态'/>", formatter: function(value, item, index) {
                //         return $.table.selectDictLabel(payTypes, item.payType);}
                // },
                {field:'equipmentValue',title: '<@ctx.i18n text = "设备原值"/>'},
                {field:'worthValue',title: '<@ctx.i18n text = "净残值"/>'},
                {field:'worth',title: '<@ctx.i18n text = "净值"/>'},
                {field:'monthDepreciation',title: '<@ctx.i18n text = "本月折旧"/>'},
                {field:'totalDepreciation',title: '<@ctx.i18n text = "累计折旧"/>'}
                //     ,formatter: function(value, row, index) {
                // return $.table.selectDictLabel(statusDatas1, value);}


                //     {field : 'id',title : ''},

                // {title:"<@ctx.i18n text = "操作"/>",align: 'left',class:'action',formatter: function(value, row, index) {
                //         var actions = [];
                //         // actions.push('<a class="" href="javascript:void(0)" title="<@ctx.i18n text = "关联流程表单"/>" onclick="taskFrom(\'' + row.id + '\')"><i class="fa icon-organization"></i></a> ');
                // //        actions.push('<a class="" href="javascript:void(0)" title="<@ctx.i18n text = "认领修改"/>" onclick="taskFromEdit(\'' + row.id + '\')">认领修改</a> ');
                //         actions.push('<a class="" href="javascript:void(0)" title="<@ctx.i18n text = "出库"/>" onclick="checkout(\'' + row.id + '\')">出库</a> ');
                //         return actions.join('');
                // }}
            ]
        };
        $.table.init(options);
    });

    /*双击行 编辑事件*/
    function onDblClickRow(row,tr,field){
        return opt.operate.edit(row.id);
    }

    function DeptDoSubmit(index, layero) {

        var body = layer.getChildFrame('body', index);
        console.log(body);
        importTable(body.find('#fileName').val());
        layer.close(index);
    }

    $('#licSelect').click(function(){
        opt.layer.open({
            type: 1,
            area: ['580px', '180px'],
            title: '<i class="fa fa-upload"></i> 导入文件 <i class="fa fa-info-circle" style="color: red"></i>!',
            shade: 0.3,
            shadeClose: true,
            resize: false,
            scrollbar: true,
            content: opt.template('upload'),
            btn: ['<i class="fa fa-check"></i> 上传',
                '<i class="fa fa-remove"></i> 取消'],
            btn1: function(index, layero){
                var form = {
                    inputForm: layero.find('#inputForm'),
                    f: layero.find('#f').val()
                };
                if (form.f == '' || !opt.common.endWith(form.f, '.xlsx'||!opt.common.endWith(form.f, '.xls'))){
                    opt.warning("<@ctx.i18n text = "文件不正确，请选择后缀为 . xls和xlsx的文件。"/>");
                    return false;
                }
                var formdata = new FormData();
                var file = layero.find('#f')[0].files[0];
                formdata.append("files", file);
                opt.common.sendAjax({
                    url: prefix + "/upload",
                    data: formdata,
                    type: "POST",
                    processData: false,
                    contentType: false,
                    success: function(result) {
                        if(result.code == opt.variable.web_status.SUCCESS){
                            opt.layer.closeAll();
                            opt.success("<@ctx.i18n text = "文件上传成功!"/>");
                            location.reload();
                        }else{
                            opt.error(result.msg);
                        }
                    }
                });
                return true;
            }
        });
    });
</script>
<script id="upload" type="text/template">
    <form id="inputForm" method="post" enctype="multipart/form-data" class="form-horizontal mt20 mb10">
        <label class="control-label col-xs-5"><span class="required">*</span> 导入文件：</label>
        <div class="col-xs-7">
            <input type="file" id="f" name="f" style="padding-top: 4px;"/>
        </div>
    </form>
</script>
<script>
    /*弹出层*/
    $('#searchall').on('click', function(){
        // layer.msg('hello');
        layer.open({
            type: 1,
            title:'组合查询',
            area: ['600px', '450px'],
            content: $("#test"),
            shade:0.0,
            btn: ['关闭'], //只是为了演示,
            btn2: function(){
                layer.closeAll();
            }
        });
    });
    /*弹出层点击查询按钮关闭弹出层*/
    $('#search').on('click',function () {
        layer.closeAll()
    })

    /*弹出层时间选择控件*/
    layui.use('laydate', function(){
        var laydate = layui.laydate;
        laydate.render({
            elem: '#timeSelect'  // 输出框id
            ,format: 'yyyy-MM-dd'
            ,trigger:'click'
        });
    });
    /*弹出层时间选择控件*/
    layui.use('laydate', function(){
        var laydate = layui.laydate;
        laydate.render({
            elem: '#timeSelect2'  // 输出框id
            ,format: 'yyyy-MM-dd'
            ,trigger:'click'
        });
    });
</script>
</@footer>
</@pageTheme>